package com.xyzh05.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;
import org.hibernate.annotations.Formula;

@Entity
@Table(name="user_info")
@Searchable
@XmlRootElement
public class UserInfo extends BaseObject implements Serializable {
	private static final long serialVersionUID = -6376557530569963899L;
	
	private Long id;
    private Long updateUser;
    private User user;
    private Date updateTime = new Date();
    private String mobilephone;
    private String qq;
    private String msn;
    private String currentDegreeCounty;
    private String currentDegreePlevel;
    private String currentDegreeSlevel;
    private String admissionYear;
    private Long undergraduateSchool;
    private Long undergraduateMajor;
    private String undergraduateGpa;
    private Long graduateSchool;
    private Long graduateMajor;
    private String graduateGpa;
    private String toefl;
    private String gre;
    private String ielts;
    private Long applyMajor;
    
    private String undergraduateSchoolName;  //本科学校
    private String undergraduateMajorName;   //本科专业
    private String applyMajorName;           //申请专业

    @Id @GeneratedValue(strategy=GenerationType.AUTO) @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    @Column(name="update_user")
    @SearchableProperty
    public Long getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(Long updateUser) {
		this.updateUser = updateUser;
	}

    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="user_id")
    public User getUser() {
        return this.user;
    }
    
    public void setUser(User user) {
        this.user = user;
    }
    
    @Column(name="update_time", nullable=false)
    @SearchableProperty
    public Date getUpdateTime() {
        return this.updateTime;
    }
    
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    
    @Column(name="mobilephone", length=16)
    @SearchableProperty
    public String getMobilephone() {
        return this.mobilephone;
    }
    
    public void setMobilephone(String mobilephone) {
        this.mobilephone = mobilephone;
    }
    
    @Column(name="qq", length=16)
    @SearchableProperty
    public String getQq() {
        return this.qq;
    }
    
    public void setQq(String qq) {
        this.qq = qq;
    }
    
    @Column(name="msn", length=16)
    @SearchableProperty
    public String getMsn() {
        return this.msn;
    }
    
    public void setMsn(String msn) {
        this.msn = msn;
    }
    
    @Column(name="current_degree_county", length=128)
    @SearchableProperty
    public String getCurrentDegreeCounty() {
        return this.currentDegreeCounty;
    }
    
    public void setCurrentDegreeCounty(String currentDegreeCounty) {
        this.currentDegreeCounty = currentDegreeCounty;
    }
    
    @Column(name="current_degree_plevel", length=128)
    @SearchableProperty
    public String getCurrentDegreePlevel() {
        return this.currentDegreePlevel;
    }
    
    public void setCurrentDegreePlevel(String currentDegreePlevel) {
        this.currentDegreePlevel = currentDegreePlevel;
    }
    
    @Column(name="current_degree_slevel", length=128)
    @SearchableProperty
    public String getCurrentDegreeSlevel() {
        return this.currentDegreeSlevel;
    }
    
    public void setCurrentDegreeSlevel(String currentDegreeSlevel) {
        this.currentDegreeSlevel = currentDegreeSlevel;
    }
    
    @Column(name="admission_year", length=16)
    @SearchableProperty
    public String getAdmissionYear() {
        return this.admissionYear;
    }
    
    public void setAdmissionYear(String admissionYear) {
        this.admissionYear = admissionYear;
    }
    
    @Column(name="undergraduate_school")
    @SearchableProperty
    public Long getUndergraduateSchool() {
        return this.undergraduateSchool;
    }
    
    public void setUndergraduateSchool(Long undergraduateSchool) {
        this.undergraduateSchool = undergraduateSchool;
    }
    
    @Column(name="undergraduate_major")
    @SearchableProperty
    public Long getUndergraduateMajor() {
        return this.undergraduateMajor;
    }
    
    public void setUndergraduateMajor(Long undergraduateMajor) {
        this.undergraduateMajor = undergraduateMajor;
    }
    
    @Column(name="undergraduate_gpa", length=16)
    @SearchableProperty
    public String getUndergraduateGpa() {
        return this.undergraduateGpa;
    }
    
    public void setUndergraduateGpa(String undergraduateGpa) {
        this.undergraduateGpa = undergraduateGpa;
    }
    
    @Column(name="graduate_school")
    @SearchableProperty
    public Long getGraduateSchool() {
        return this.graduateSchool;
    }
    
    public void setGraduateSchool(Long graduateSchool) {
        this.graduateSchool = graduateSchool;
    }
    
    @Column(name="graduate_major")
    @SearchableProperty
    public Long getGraduateMajor() {
        return this.graduateMajor;
    }
    
    public void setGraduateMajor(Long graduateMajor) {
        this.graduateMajor = graduateMajor;
    }
    
    @Column(name="graduate_gpa", length=16)
    @SearchableProperty
    public String getGraduateGpa() {
        return this.graduateGpa;
    }
    
    public void setGraduateGpa(String graduateGpa) {
        this.graduateGpa = graduateGpa;
    }
    
    @Column(name="toefl", length=16)
    @SearchableProperty
    public String getToefl() {
        return this.toefl;
    }
    
    public void setToefl(String toefl) {
        this.toefl = toefl;
    }
    
    @Column(name="gre", length=16)
    @SearchableProperty
    public String getGre() {
        return this.gre;
    }
    
    public void setGre(String gre) {
        this.gre = gre;
    }
    
    @Column(name="ielts", length=16)
    @SearchableProperty
    public String getIelts() {
        return this.ielts;
    }
    
    public void setIelts(String ielts) {
        this.ielts = ielts;
    }
    
    @Column(name="apply_major")
    @SearchableProperty
    public Long getApplyMajor() {
        return this.applyMajor;
    }
    
    public void setApplyMajor(Long applyMajor) {
        this.applyMajor = applyMajor;
    }    
    
    @Formula("(select s.name from School s where s.id=undergraduate_school)")
    public String getUndergraduateSchoolName() {
		return undergraduateSchoolName;
	}

	public void setUndergraduateSchoolName(String undergraduateSchoolName) {
		this.undergraduateSchoolName = undergraduateSchoolName;
	}

	@Formula("(select m.name from Major m where m.id=undergraduate_major)")
	public String getUndergraduateMajorName() {
		return undergraduateMajorName;
	}

	public void setUndergraduateMajorName(String undergraduateMajorName) {
		this.undergraduateMajorName = undergraduateMajorName;
	}

	@Formula("(select m.name from Major m where m.id=apply_major)")
	public String getApplyMajorName() {
		return applyMajorName;
	}

	public void setApplyMajorName(String applyMajorName) {
		this.applyMajorName = applyMajorName;
	}

	public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserInfo pojo = (UserInfo) o;

        if (updateUser != null ? !updateUser.equals(pojo.updateUser) : pojo.updateUser != null) return false;
        if (user != null ? !user.equals(pojo.user) : pojo.user != null) return false;
        if (updateTime != null ? !updateTime.equals(pojo.updateTime) : pojo.updateTime != null) return false;
        if (mobilephone != null ? !mobilephone.equals(pojo.mobilephone) : pojo.mobilephone != null) return false;
        if (qq != null ? !qq.equals(pojo.qq) : pojo.qq != null) return false;
        if (msn != null ? !msn.equals(pojo.msn) : pojo.msn != null) return false;
        if (currentDegreeCounty != null ? !currentDegreeCounty.equals(pojo.currentDegreeCounty) : pojo.currentDegreeCounty != null) return false;
        if (currentDegreePlevel != null ? !currentDegreePlevel.equals(pojo.currentDegreePlevel) : pojo.currentDegreePlevel != null) return false;
        if (currentDegreeSlevel != null ? !currentDegreeSlevel.equals(pojo.currentDegreeSlevel) : pojo.currentDegreeSlevel != null) return false;
        if (admissionYear != null ? !admissionYear.equals(pojo.admissionYear) : pojo.admissionYear != null) return false;
        if (undergraduateSchool != null ? !undergraduateSchool.equals(pojo.undergraduateSchool) : pojo.undergraduateSchool != null) return false;
        if (undergraduateMajor != null ? !undergraduateMajor.equals(pojo.undergraduateMajor) : pojo.undergraduateMajor != null) return false;
        if (undergraduateGpa != null ? !undergraduateGpa.equals(pojo.undergraduateGpa) : pojo.undergraduateGpa != null) return false;
        if (graduateSchool != null ? !graduateSchool.equals(pojo.graduateSchool) : pojo.graduateSchool != null) return false;
        if (graduateMajor != null ? !graduateMajor.equals(pojo.graduateMajor) : pojo.graduateMajor != null) return false;
        if (graduateGpa != null ? !graduateGpa.equals(pojo.graduateGpa) : pojo.graduateGpa != null) return false;
        if (toefl != null ? !toefl.equals(pojo.toefl) : pojo.toefl != null) return false;
        if (gre != null ? !gre.equals(pojo.gre) : pojo.gre != null) return false;
        if (ielts != null ? !ielts.equals(pojo.ielts) : pojo.ielts != null) return false;
        if (applyMajor != null ? !applyMajor.equals(pojo.applyMajor) : pojo.applyMajor != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (updateUser != null ? updateUser.hashCode() : 0);
        result = 31 * result + (user != null ? user.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (mobilephone != null ? mobilephone.hashCode() : 0);
        result = 31 * result + (qq != null ? qq.hashCode() : 0);
        result = 31 * result + (msn != null ? msn.hashCode() : 0);
        result = 31 * result + (currentDegreeCounty != null ? currentDegreeCounty.hashCode() : 0);
        result = 31 * result + (currentDegreePlevel != null ? currentDegreePlevel.hashCode() : 0);
        result = 31 * result + (currentDegreeSlevel != null ? currentDegreeSlevel.hashCode() : 0);
        result = 31 * result + (admissionYear != null ? admissionYear.hashCode() : 0);
        result = 31 * result + (undergraduateSchool != null ? undergraduateSchool.hashCode() : 0);
        result = 31 * result + (undergraduateMajor != null ? undergraduateMajor.hashCode() : 0);
        result = 31 * result + (undergraduateGpa != null ? undergraduateGpa.hashCode() : 0);
        result = 31 * result + (graduateSchool != null ? graduateSchool.hashCode() : 0);
        result = 31 * result + (graduateMajor != null ? graduateMajor.hashCode() : 0);
        result = 31 * result + (graduateGpa != null ? graduateGpa.hashCode() : 0);
        result = 31 * result + (toefl != null ? toefl.hashCode() : 0);
        result = 31 * result + (gre != null ? gre.hashCode() : 0);
        result = 31 * result + (ielts != null ? ielts.hashCode() : 0);
        result = 31 * result + (applyMajor != null ? applyMajor.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("updateUser").append("='").append(getUpdateUser()).append("', ");
        sb.append("user").append("='").append(getUser()).append("', ");
        sb.append("updateTime").append("='").append(getUpdateTime()).append("', ");
        sb.append("mobilephone").append("='").append(getMobilephone()).append("', ");
        sb.append("qq").append("='").append(getQq()).append("', ");
        sb.append("msn").append("='").append(getMsn()).append("', ");
        sb.append("currentDegreeCounty").append("='").append(getCurrentDegreeCounty()).append("', ");
        sb.append("currentDegreePlevel").append("='").append(getCurrentDegreePlevel()).append("', ");
        sb.append("currentDegreeSlevel").append("='").append(getCurrentDegreeSlevel()).append("', ");
        sb.append("admissionYear").append("='").append(getAdmissionYear()).append("', ");
        sb.append("undergraduateSchool").append("='").append(getUndergraduateSchool()).append("', ");
        sb.append("undergraduateMajor").append("='").append(getUndergraduateMajor()).append("', ");
        sb.append("undergraduateGpa").append("='").append(getUndergraduateGpa()).append("', ");
        sb.append("graduateSchool").append("='").append(getGraduateSchool()).append("', ");
        sb.append("graduateMajor").append("='").append(getGraduateMajor()).append("', ");
        sb.append("graduateGpa").append("='").append(getGraduateGpa()).append("', ");
        sb.append("toefl").append("='").append(getToefl()).append("', ");
        sb.append("gre").append("='").append(getGre()).append("', ");
        sb.append("ielts").append("='").append(getIelts()).append("', ");
        sb.append("applyMajor").append("='").append(getApplyMajor()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
